package com.tencent.wxcloudrun.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.tencent.wxcloudrun.config.ApiResponse;
import com.tencent.wxcloudrun.manager.WxManager;
import com.tencent.wxcloudrun.vo.request.wx.*;
import com.tencent.wxcloudrun.vo.response.wx.*;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
 * @author Ryan Zhao
 *         <p>
 *         Copyright: Copyright (c) 2023
 *         </p>
 * @version 1.0
 * @date 2023-08-26 16:14
 * @description: 微信接口
 */
@RestController
@RequestMapping("/wx")
@Api(value = "微信接口", tags = {"微信接口"})
public class WxController {

    @Resource
    private WxManager wxManager;

    @PostMapping(value = "/getPhoneNumber")
    @ApiOperation(value = "获取手机号")
    @ApiImplicitParams({@ApiImplicitParam(name = "request", value = "获取手机号请求入参", dataType = "WxGetPhoneNumberRequest",
        paramType = "body", required = true)})
    ApiResponse<WxGetPhoneNumberResponse> getPhoneNumber(@RequestBody WxGetPhoneNumberRequest request) {
        return ApiResponse.ok(wxManager.getPhoneNumber(request));
    }

    @PostMapping(value = "/login")
    @ApiOperation(value = "登录")
    @ApiImplicitParams({@ApiImplicitParam(name = "request", value = "微信登录请求入参", dataType = "WxLoginRequest",
        paramType = "body", required = true)})
    ApiResponse<WxLoginResponse> login(@RequestBody WxLoginRequest request) {
        return ApiResponse.ok(wxManager.login(request));
    }

    @PostMapping(value = "/sendActiBegnSubsMsg")
    @ApiOperation(value = "推送活动开始订阅消息")
    @ApiImplicitParams({@ApiImplicitParam(name = "request", value = "微信活动开始消息推送请求入参",
        dataType = "WxSendActiBegnSubsMsgRequest", paramType = "body", required = true)})
    ApiResponse<Object> sendActiBegnSubsMsg(@RequestBody WxSendActiBegnSubsMsgRequest request) {
        wxManager.sendActiBegnSubsMsg(request);
        return ApiResponse.ok();
    }

    @PostMapping(value = "/qryRid")
    @ApiOperation(value = "查询错误信息")
    @ApiImplicitParams({@ApiImplicitParam(name = "request", value = "查询Rid请求入参", dataType = "WxQryRidRequest",
        paramType = "body", required = true)})
    ApiResponse<Object> qryRid(@RequestBody WxQryRidRequest request) {
        return ApiResponse.ok(wxManager.qryRid(request));
    }

    @PostMapping(value = "/wxPay")
    @ApiOperation(value = "微信支付")
    @ApiImplicitParams({@ApiImplicitParam(name = "request", value = "微信支付请求入参", dataType = "WxPayRequest",
        paramType = "body", required = true)})
    ApiResponse<WxPayResponse> wxPay(@RequestBody WxPayRequest request) {
        return ApiResponse.ok(wxManager.wxPay(request));
    }

    @PostMapping(value = "/wxQryOrder")
    @ApiOperation(value = "微信订单查询")
    @ApiImplicitParams({@ApiImplicitParam(name = "request", value = "微信订单查询请求入参", dataType = "WxQryOrderRequest",
        paramType = "body", required = true)})
    ApiResponse<WxQryOrderResponse> wxQryOrder(@RequestBody WxQryOrderRequest request) {
        return ApiResponse.ok(wxManager.wxQryOrder(request));
    }

    @PostMapping(value = "/wxTraceWaybill")
    @ApiOperation(value = "微信传运单接口")
    @ApiImplicitParams({@ApiImplicitParam(name = "request", value = "微信传运单接口请求入参", dataType = "WxTraceWaybillRequest",
        paramType = "body", required = true)})
    ApiResponse<WxTraceWaybillResponse> wxTraceWaybill(@RequestBody WxTraceWaybillRequest request) {
        return ApiResponse.ok(wxManager.wxTraceWaybill(request));
    }

    @PostMapping(value = "/wxDownloadfile")
    @ApiOperation(value = "微信下载文件接口")
    @ApiImplicitParams({@ApiImplicitParam(name = "request", value = "微信下载文件接口请求入参", dataType = "WxDownloadfileRequest",
        paramType = "body", required = true)})
    ApiResponse<WxDownloadfileResponse> wxDownloadfile(@RequestBody WxDownloadfileRequest request) {
        return ApiResponse.ok(wxManager.wxDownloadfile(request));
    }

    @PostMapping(value = "/wxMsgSecCheck")
    @ApiOperation(value = "微信文本内容安全识别接口")
    @ApiImplicitParams({@ApiImplicitParam(name = "request", value = "微信文本内容安全校验请求入参", dataType = "WxMsgSecCheckRequest",
        paramType = "body", required = true)})
    ApiResponse<WxMsgSecCheckResponse> wxMsgSecCheck(@RequestBody WxMsgSecCheckRequest request) {
        return ApiResponse.ok(wxManager.wxMsgSecCheck(request));
    }

    @PostMapping(value = "/wxMediaCheckAsync")
    @ApiOperation(value = "微信音视频内容安全识别接口")
    @ApiImplicitParams({@ApiImplicitParam(name = "request", value = "微信音视频内容安全识别请求入参",
        dataType = "WxMediaCheckAsyncRequest", paramType = "body", required = true)})
    ApiResponse<WxMediaCheckAsyncResponse> wxMediaCheckAsync(@RequestBody WxMediaCheckAsyncRequest request) {
        return ApiResponse.ok(wxManager.wxMediaCheckAsync(request));
    }

}
